package com.ushine.web.security.handler;

import com.ushine.web.security.response.SecurityResponse;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: yls
 * @Date: 2021/8/19 15:50
 * @Description: 权限不足处理器
 * @Version 1.0
 */
@Component
public class RestAuthenticationAccessDeniedHandler implements AccessDeniedHandler {
    @Resource
    SecurityResponse securityResponse;

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
        securityResponse.getResponse(response, 500, "权限不足！！！");
    }
}
